use std::process::{Command, exit};
use std::str;

static CARGOENV: &str = "cargo:rustc-env=";

fn main() {
    let time_c = Command::new("date").args(&["+%Y%m%d%H%M%S"]).output();

    match time_c {
        Ok(t) => {
            let time;
            unsafe {
                time = str::from_utf8_unchecked( &t.stdout );
            }   
            println!("{}COMPILED_AT={}", CARGOENV, time);
        }   
        Err(_) => exit(1)
    }

    let git_c = Command::new("git").args(&["rev-parse", "HEAD"]).output();
    match git_c {
        Ok(g) => {  
            let git_head;
            unsafe {
                git_head = str::from_utf8_unchecked( &g.stdout );
            }
            println!("{}GIT_HEAD={}", CARGOENV, git_head);
        },
        Err(_) => exit(1)
    }
}